<?php
/**
 * 第3步，填写安装信息
 */
include_once dirname(__FILE__).'/_config.php';
if(empty($_POST['check'])){
	set(get_html('input.html'));
	##^^ 安全码
	$sitekey = array();
	for($i = 0; $i < 5; $i ++){
		$sitekey[] = strtoupper(genRandomString(5));
	}
	assign('sitekey', implode('-', $sitekey));
	##^^ 前缀
	if($_SERVER['HTTP_HOST'] == 'localhost' || $_SERVER['HTTP_HOST'] == '127.0.0.1'){
		$__self = dirname(dirname($_SERVER ['PHP_SELF']));
		$__dir  = str_replace('//', '/', str_replace('\\', '/', $__self).'/');
		$pre = str_replace('/', '_', $__dir);
	}else{
		$hostarr = explode('.', $_SERVER['HTTP_HOST']);
		array_pop($hostarr);
		if($hostarr[0] == 'www'){
			array_shift($hostarr);
		}
		$pre = implode('_', $hostarr);
	}
	assign('pre', $pre);
	view();
}else{
	// $_POST['driver']	= empty($_POST['driver'])	? '' : trim($_POST['driver']);
	$_POST['db_host']	= empty($_POST['db_host'])	? '' : trim($_POST['db_host']);
	$_POST['db_user']	= empty($_POST['db_user'])	? '' : trim($_POST['db_user']);
	$_POST['db_pass']	= empty($_POST['db_pass'])	? '' : trim($_POST['db_pass']);
	$_POST['db_name']	= empty($_POST['db_name'])	? '' : trim($_POST['db_name']);
	$_POST['db_pre']	= empty($_POST['db_pre'])	? '' : trim($_POST['db_pre']);

	$dbname_not_exists = check_db($_POST['db_host'], $_POST['db_user'], $_POST['db_pass'], $_POST['db_name'], $_POST['db_pre']);
	echo $dbname_not_exists;
}
